package com.sgb.kjwl.viewmodel.self.mine

import android.content.Context
import com.sgb.kjwl.api.APIManager
import com.sgb.kjwl.view.ui.activity.WebViewX5HostActivity
import com.swgk.core.base.BaseViewModel
import com.swgk.core.base.api.ICallBack
import com.swgk.core.base.model.entity.BaseEntity
import com.swgk.core.base.model.entity.H5ReEntity


class FastMenuViewModel : BaseViewModel() {

    /**
     * 通过标识来获取跳转连接
     *
     * @param map
     */
    fun getStringUrl(context: Context, type : String, urlId : String) {
        APIManager.getInstance().pickAPI.getUrlSetting(type)
            .enqueue(object : ICallBack<BaseEntity<H5ReEntity>>(true, true) {
                override fun onSuccess(data: BaseEntity<H5ReEntity>) {
                    if (data.state == APIManager.RESPONSE_OK) {
                        val url = data.data.url + urlId
                        WebViewX5HostActivity.start(context, url)
                    }
                }
            })
    }
}